var express = require('express');
var router = express.Router();


router.get('/', function(req, res, next) {

  // 读取数据库，解析数据
  const arr = [{
    title:"新闻1",
    href:"/news/page?id=1"
  },{
    title:"新闻2",
    href:"/news/page?id=2"
  },{
    title:"新闻3",
    href:"/news/page?id=3"
  }];

  res.render("news", {
    title: "这是新闻列表",
    newsList:arr
  })
});

router.get('/page', function(req, res, next) {
  // 解析get数据，使用该数据
  const id = req.query.id;

  res.render("page", {
    msg: {
      title:`新闻 ${id} 标题`,
      content:"新闻内容",
      time:"2022.6.13"
    }
  })
});

module.exports = router;
